-
-
Notifications
You must be signed in to change notification settings - Fork 836
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: support vyper files for tests #2684
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2684 +/- ##
===========================================
- Coverage 86.29% 52.12% -34.18%
===========================================
Files 91 91
Lines 9739 9737 -2
Branches 2466 2428 -38
===========================================
- Hits 8404 5075 -3329
- Misses 833 4061 +3228
- Partials 502 601 +99
Continue to review full report at Codecov.
|
@pytest.mark.parametrize( | ||
"vyper_contract", ["constants/test_constantGetter1_Success.vy"], indirect=True | ||
) | ||
def test_constant_success_2(vyper_contract): | ||
assert vyper_contract.foo() == 123 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, this is clever. Basically, reuse compiled "successful parsing" test cases to additionally perform other checks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's correct. This is more deliberate as compared to automatically creating fixtures for "successful parsing" test cases (which I still cannot figure out, and on further thought could be more confusing if all these contracts appear in the global namespace).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would the array of filenames passed in create multiple parametrized tests?
Also, some of the folders get really deep. I wonder if it could just assume a local path e.g. ./test_constantGetter1_Success.vy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would the array of filenames passed in create multiple parametrized tests?
Yes, I have updated the example to better demonstrate this.
Also, some of the folders get really deep. I wonder if it could just assume a local path e.g. ./test_constantGetter1_Success.vy
Do you mean that there will be some sort of collection process in the current directory and subdirectories to get the Vyper files based on the filename provided?
1ba2617
to
3ef9776
Compare
What I did
tests/conftest.py
to handle the testing of compilation outcomes for.vy
files (as per https://docs.pytest.org/en/6.2.x/example/nonpython.html)How I did it
The Vyper files need to adhere to the syntax
test_DESCRIPTION_OUTCOME
whereDESCRIPTION
is non-consequential andOUTCOME
is eitherSuccess
, aVyperException
class name, orFail
(unhandled exception).OUTCOME
is extracted upon the initialisation of each Vyper test file.For each test file, we attempt to compile it using
compile_files
, and check the compilation outcome against the extractedOUTCOME
.Example of a failing test:

How to verify it
Run
pytest tests/parser/syntax/constants/
to see a demo against two sample contracts fromtest_constants.py
. You can also edit the Vyper test files to see what a failing test look like.Description for the changelog
Handle Vyper test files
Cute Animal Picture